package com.YCH.login.controller.v1;

import com.YCH.apis.register.apis.MailControllerApi;
import com.YCH.login.service.SengMSGService;
import com.YCH.model.common.dtos.ResponseResult;
import com.YCH.model.user.dtos.registerDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 16554
 */
@RestController
@RequestMapping("/api/v1/sms_code")
public class MailUtilsController implements MailControllerApi {
    @Autowired
    private SengMSGService sengMSGService;

    @Override
    @GetMapping(value = "/active_code")
    public ResponseResult sendCode(HttpServletRequest request, @RequestParam(value = "EMAIL",required = true) String EMAIL,
                                   @RequestParam(value = "UUID",required = false) String UUID) {
        registerDto registerDto = new registerDto();
        registerDto.setEmail(EMAIL);
        if(UUID!=null){
            String uuid = UUID.replace("-","");
            registerDto.setUuid(uuid);
        }
        return sengMSGService.sendActiveCode(request,registerDto);
    }

}
